﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace One_day.Areas.admin.Controllers
{
    public class OrderController : Controller
    {
        // GET: admin/Order
        public ActionResult Index()
        {
            One_day.Models.YichenEntities db = new Models.YichenEntities();
            List<One_day.Models.T_Shop_Order> order = db.T_Shop_Order.ToList();
            ViewBag.order = order;
            return View();
        }
        public ActionResult Select()
        {
            One_day.Models.YichenEntities db = new Models.YichenEntities();
            //1为前台用户，查询出来给后台用
            List<One_day.Models.T_Base_User> user = db.T_Base_User.Where(m => m.Type == 1).ToList();
            ViewBag.user = user;
            return View();
        }
        /// <summary>
        /// 返回查询后的结果
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectResult(String year_from,String month_from,String day_from,String year_to,String month_to,String day_to)//进行日期检索操作
        {
            DateTime date_from = new DateTime(int.Parse(year_from),int.Parse(month_from),int.Parse(day_from),0,0,0);
            DateTime date_to = new DateTime(int.Parse(year_to), int.Parse(month_to), int.Parse(day_to), 0, 0, 0);
            One_day.Models.YichenEntities db = new Models.YichenEntities();
            List<One_day.Models.T_Shop_Order> order = db.T_Shop_Order.Where(m => m.Time >= date_from && m.Time <= date_to).ToList();
            ViewBag.order = order;
            var num = 0;
            foreach (var item in order)
                num++;
            ViewBag.num = num;
            return View();
        }
    }
}